1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.HeaderBar;
26 
27 private import adw.c.functions;
28 public  import adw.c.types;
29 private import glib.ConstructionException;
30 private import glib.Str;
31 private import glib.c.functions;
32 private import gobject.ObjectG;
33 private import gtk.AccessibleIF;
34 private import gtk.AccessibleT;
35 private import gtk.BuildableIF;
36 private import gtk.BuildableT;
37 private import gtk.ConstraintTargetIF;
38 private import gtk.ConstraintTargetT;
39 private import gtk.Widget;
40 
41 
42 /**
43  * A title bar widget.
44  * 
45  * <picture>
46  * <source srcset="header-bar-dark.png" media="(prefers-color-scheme: dark)">
47  * <img src="header-bar.png" alt="header-bar">
48  * </picture>
49  * 
50  * `AdwHeaderBar` is similar to [class@Gtk.HeaderBar], but provides additional
51  * features compared to it. Refer to `GtkHeaderBar` for details.
52  * 
53  * [property@HeaderBar:centering-policy] allows to enforce strict centering of
54  * the title widget, this is useful for [class@ViewSwitcherTitle].
55  * 
56  * [property@HeaderBar:show-start-title-buttons] and
57  * [property@HeaderBar:show-end-title-buttons] allow to easily create split
58  * header bar layouts using [class@Leaflet], as follows:
59  * 
60  * ```xml
61  * <object class="AdwLeaflet" id="leaflet">
62  * <child>
63  * <object class="GtkBox">
64  * <property name="orientation">vertical</property>
65  * <child>
66  * <object class="AdwHeaderBar">
67  * <binding name="show-end-title-buttons">
68  * <lookup name="folded">leaflet</lookup>
69  * </binding>
70  * </object>
71  * </child>
72  * <!-- ... -->
73  * </object>
74  * </child>
75  * <!-- ... -->
76  * <child>
77  * <object class="GtkBox">
78  * <property name="orientation">vertical</property>
79  * <property name="hexpand">True</property>
80  * <child>
81  * <object class="AdwHeaderBar">
82  * <binding name="show-start-title-buttons">
83  * <lookup name="folded">leaflet</lookup>
84  * </binding>
85  * </object>
86  * </child>
87  * <!-- ... -->
88  * </object>
89  * </child>
90  * </object>
91  * ```
92  * 
93  * <picture>
94  * <source srcset="header-bar-split-dark.png" media="(prefers-color-scheme: dark)">
95  * <img src="header-bar-split.png" alt="header-bar-split">
96  * </picture>
97  * 
98  * ## CSS nodes
99  * 
100  * ```
101  * headerbar
102  * ╰── windowhandle
103  * ╰── box
104  * ├── widget
105  * │   ╰── box.start
106  * │       ├── windowcontrols.start
107  * │       ╰── [other children]
108  * ├── [Title Widget]
109  * ╰── widget
110  * ╰── box.end
111  * ├── [other children]
112  * ╰── windowcontrols.end
113  * ```
114  * 
115  * `AdwHeaderBar`'s CSS node is called `headerbar`. It contains a `windowhandle`
116  * subnode, which contains a `box` subnode, which contains two `widget` subnodes
117  * at the start and end of the header bar, each of which contains a `box`
118  * subnode with the `.start` and `.end` style classes respectively, as well as a
119  * center node that represents the title.
120  * 
121  * Each of the boxes contains a `windowcontrols` subnode, see
122  * [class@Gtk.WindowControls] for details, as well as other children.
123  * 
124  * ## Accessibility
125  * 
126  * `AdwHeaderBar` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role.
127  *
128  * Since: 1.0
129  */
130 public class HeaderBar : Widget
131 {
132 	/** the main Gtk struct */
133 	protected AdwHeaderBar* adwHeaderBar;
134 
135 	/** Get the main Gtk struct */
136 	public AdwHeaderBar* getHeaderBarStruct(bool transferOwnership = false)
137 	{
138 		if (transferOwnership)
139 			ownedRef = false;
140 		return adwHeaderBar;
141 	}
142 
143 	/** the main Gtk struct as a void* */
144 	protected override void* getStruct()
145 	{
146 		return cast(void*)adwHeaderBar;
147 	}
148 
149 	/**
150 	 * Sets our main struct and passes it to the parent class.
151 	 */
152 	public this (AdwHeaderBar* adwHeaderBar, bool ownedRef = false)
153 	{
154 		this.adwHeaderBar = adwHeaderBar;
155 		super(cast(GtkWidget*)adwHeaderBar, ownedRef);
156 	}
157 
158 
159 	/** */
160 	public static GType getType()
161 	{
162 		return adw_header_bar_get_type();
163 	}
164 
165 	/**
166 	 * Creates a new `AdwHeaderBar`.
167 	 *
168 	 * Returns: the newly created `AdwHeaderBar`.
169 	 *
170 	 * Since: 1.0
171 	 *
172 	 * Throws: ConstructionException GTK+ fails to create the object.
173 	 */
174 	public this()
175 	{
176 		auto __p = adw_header_bar_new();
177 
178 		if(__p is null)
179 		{
180 			throw new ConstructionException("null returned by new");
181 		}
182 
183 		this(cast(AdwHeaderBar*) __p);
184 	}
185 
186 	/**
187 	 * Gets the policy for aligning the center widget.
188 	 *
189 	 * Returns: the centering policy
190 	 *
191 	 * Since: 1.0
192 	 */
193 	public AdwCenteringPolicy getCenteringPolicy()
194 	{
195 		return adw_header_bar_get_centering_policy(adwHeaderBar);
196 	}
197 
198 	/**
199 	 * Gets the decoration layout for @self.
200 	 *
201 	 * Returns: the decoration layout
202 	 *
203 	 * Since: 1.0
204 	 */
205 	public string getDecorationLayout()
206 	{
207 		return Str.toString(adw_header_bar_get_decoration_layout(adwHeaderBar));
208 	}
209 
210 	/**
211 	 * Gets whether to show title buttons at the end of @self.
212 	 *
213 	 * Returns: `TRUE` if title buttons at the end are shown
214 	 *
215 	 * Since: 1.0
216 	 */
217 	public bool getShowEndTitleButtons()
218 	{
219 		return adw_header_bar_get_show_end_title_buttons(adwHeaderBar) != 0;
220 	}
221 
222 	/**
223 	 * Gets whether to show title buttons at the start of @self.
224 	 *
225 	 * Returns: `TRUE` if title buttons at the start are shown
226 	 *
227 	 * Since: 1.0
228 	 */
229 	public bool getShowStartTitleButtons()
230 	{
231 		return adw_header_bar_get_show_start_title_buttons(adwHeaderBar) != 0;
232 	}
233 
234 	/**
235 	 * Gets the title widget widget of @self.
236 	 *
237 	 * Returns: the title widget
238 	 *
239 	 * Since: 1.0
240 	 */
241 	public Widget getTitleWidget()
242 	{
243 		auto __p = adw_header_bar_get_title_widget(adwHeaderBar);
244 
245 		if(__p is null)
246 		{
247 			return null;
248 		}
249 
250 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
251 	}
252 
253 	/**
254 	 * Adds @child to @self, packed with reference to the end of @self.
255 	 *
256 	 * Params:
257 	 *     child = the widget to be added to @self
258 	 *
259 	 * Since: 1.0
260 	 */
261 	public void packEnd(Widget child)
262 	{
263 		adw_header_bar_pack_end(adwHeaderBar, (child is null) ? null : child.getWidgetStruct());
264 	}
265 
266 	/**
267 	 * Adds @child to @self, packed with reference to the start of the @self.
268 	 *
269 	 * Params:
270 	 *     child = the widget to be added to @self
271 	 *
272 	 * Since: 1.0
273 	 */
274 	public void packStart(Widget child)
275 	{
276 		adw_header_bar_pack_start(adwHeaderBar, (child is null) ? null : child.getWidgetStruct());
277 	}
278 
279 	/**
280 	 * Removes a child from @self.
281 	 *
282 	 * The child must have been added with [method@HeaderBar.pack_start],
283 	 * [method@HeaderBar.pack_end] or [property@HeaderBar:title-widget].
284 	 *
285 	 * Params:
286 	 *     child = the child to remove
287 	 *
288 	 * Since: 1.0
289 	 */
290 	public void remove(Widget child)
291 	{
292 		adw_header_bar_remove(adwHeaderBar, (child is null) ? null : child.getWidgetStruct());
293 	}
294 
295 	/**
296 	 * Sets the policy for aligning the center widget.
297 	 *
298 	 * Params:
299 	 *     centeringPolicy = the centering policy
300 	 *
301 	 * Since: 1.0
302 	 */
303 	public void setCenteringPolicy(AdwCenteringPolicy centeringPolicy)
304 	{
305 		adw_header_bar_set_centering_policy(adwHeaderBar, centeringPolicy);
306 	}
307 
308 	/**
309 	 * Sets the decoration layout for @self.
310 	 *
311 	 * Params:
312 	 *     layout = a decoration layout
313 	 *
314 	 * Since: 1.0
315 	 */
316 	public void setDecorationLayout(string layout)
317 	{
318 		adw_header_bar_set_decoration_layout(adwHeaderBar, Str.toStringz(layout));
319 	}
320 
321 	/**
322 	 * Sets whether to show title buttons at the end of @self.
323 	 *
324 	 * Params:
325 	 *     setting = `TRUE` to show standard title buttons
326 	 *
327 	 * Since: 1.0
328 	 */
329 	public void setShowEndTitleButtons(bool setting)
330 	{
331 		adw_header_bar_set_show_end_title_buttons(adwHeaderBar, setting);
332 	}
333 
334 	/**
335 	 * Sets whether to show title buttons at the start of @self.
336 	 *
337 	 * Params:
338 	 *     setting = `TRUE` to show standard title buttons
339 	 *
340 	 * Since: 1.0
341 	 */
342 	public void setShowStartTitleButtons(bool setting)
343 	{
344 		adw_header_bar_set_show_start_title_buttons(adwHeaderBar, setting);
345 	}
346 
347 	/**
348 	 * Sets the title widget for @self.
349 	 *
350 	 * Params:
351 	 *     titleWidget = a widget to use for a title
352 	 *
353 	 * Since: 1.0
354 	 */
355 	public void setTitleWidget(Widget titleWidget)
356 	{
357 		adw_header_bar_set_title_widget(adwHeaderBar, (titleWidget is null) ? null : titleWidget.getWidgetStruct());
358 	}
359 }